package com.shujia.flink.tf;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class Demo3Filter {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStream<String> linesDS = env.readTextFile("flink/data/students.csv");

        //匿名内部类
        linesDS.filter(new FilterFunction<String>() {
            @Override
            public boolean filter(String line) throws Exception {
                String clazz = line.split(",")[4];
                return "文科一班".equals(clazz);
            }
        });//.print();


        //lambda表达式
        linesDS.filter(line -> "文科一班".equals(line.split(",")[4])).print();

        env.execute();

    }
}
